//
//  InviteRankingHeaderView.m
//  PCR
//
//  Created by shumei on 16/7/11.
//  Copyright © 2016年 shumei. All rights reserved.
//

#import "InviteRankingHeaderView.h"

@implementation InviteRankingHeaderView
{
    NSArray * btnNameArray;
    NSInteger currentTag;
    BOOL isSelect;
}
-(instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self)
    {
        btnNameArray = @[@"全国总排名",@"最近30天排名"];
        [self creatHearderView];
    }
    return self;
}

-(void)creatHearderView
{
    for (int x = 0; x < 2; x ++)
    {
        UIButton * button = [UIButton buttonWithType:0];
        button.frame = CGRectMake(x * MainSCreen.width / 2, 0, MainSCreen.width / 2, self.frame.size.height);
        [button setTitle:btnNameArray[x] forState:0];
        UIColor * color_normal = nil;
        if (currentTag == x)
        {
            color_normal = [UIColor orangeColor];
        }
        else
        {
            color_normal = [UIColor blackColor];
        }
        [button setTitleColor:color_normal forState:0];
        button.tag = x + 1;
        button.titleLabel.font = [UIFont systemFontOfSize:14.0];
        [button addTarget:self action:@selector(BtnClick:) forControlEvents:UIControlEventTouchUpInside];
        [self addSubview:button];
    }
    UILabel * label = [[UILabel alloc]initWithFrame:CGRectMake(MainSCreen.width / 2,(self.frame.size.height / 2)/2 , 1, self.frame.size.height / 2)];
    label.backgroundColor = [UIColor lightGrayColor];
    [self addSubview:label];

}
-(void)BtnClick:(UIButton *)btn
{
    if (btn.tag - 1 == currentTag)
    {
        return;
    }
    currentTag = btn.tag - 1;
    
    [self.nextResponder routerEventWithName:@"InviteRankingHeaderBtn" userInfo:@{@"tag":[NSNumber numberWithInteger:btn.tag]}];
}
@end
